﻿Imports DTO
Imports System.Data.OleDb
Public Class BangCapDAO

    Public Function CapNhatBangCap(ByVal sql As String) As Integer
        DataProvider.OpenConnecttion()
        Dim kq As Integer = DataProvider.ExecInsert(sql)
        DataProvider.CloseConnect()
        Return kq
    End Function

    Public Function ThemBangCap(ByVal sql As String) As Integer
        DataProvider.OpenConnecttion()
        Dim kq As Integer = DataProvider.ExecInsert(sql)
        DataProvider.CloseConnect()
        Return kq
    End Function

    Public Function LayDSBangCap() As List(Of BangCapDTO)
        Dim sql As String = "Select MaBangCap,TenBangCap From BANGCAP"
        DataProvider.OpenConnecttion()
        Dim reader As OleDbDataReader = DataProvider.ExecSelect(sql)
        Dim ds As New List(Of BangCapDTO)()
        While reader.Read
            Dim bc As New BangCapDTO()
            bc.MaBangCap = reader.GetInt32(0)
            bc.TenBangCap = reader.GetString(1)
            ds.Add(bc)
        End While
        DataProvider.CloseConnect()
        Return ds
    End Function
End Class
